from datetime import *

from engineUtil import *
from Goals import *

class Person:
    def __init__(self):
        self.goals = []
        self.activeGoal = None
        self.position = (10,10)
        self.activity = None


# Should be person.goals

p1 = Person()
p2 = Person()

p1.goals = [GoalIdle(), GoalSleep()]
p1.name = "Thomas"
goal = GoalWork()
goal.position = (30,30)
p1.goals.append(goal)

p2.goals = [GoalIdle(), GoalSleep()]
p2.name = "Kathrine"
goal = GoalWork()
goal.position = (20,20)
p2.goals.append(goal)

people = [p1, p2]

def simulate(startTime, dt):
    time = startTime
    endTime = startTime + dt
    timeStep = timedelta(minutes=30)
    while time < endTime:
        for person in people:
            person.activeGoal = None
            for goal in person.goals:
                goal.setPriority(person.position, time)
                if person.activeGoal == None or goal.priority > person.activeGoal.priority:
                    person.activeGoal = goal
            person.position, person.activity = person.activeGoal.takeTimeStep(person.position, person.activity, timeStep)
            print time, person.name, person.activeGoal.name, person.activity, person.position
        time = time + timeStep

